package com.example.chinesenation.Config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author sakuraFallingDown
 * @version 1.0
 * @date 2020/12/14 11:41
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig  {
    @Bean
    Docket getDocket(Environment environment){
        Profiles profiles=Profiles.of("dev");
        boolean flag=environment.acceptsProfiles(profiles);

        ApiInfo info= new ApiInfo("中华民族文旅资源大数据平台接口文档"
                , "后端项目的接口文档"
                , "1.0"
                , "urn:tos"
                , new Contact("SakuraFallingDown", "", "2607912272@qq.com")
                , "Apache 2.0"
                , "http://www.apache.org/licenses/LICENSE-2.0"
                , new ArrayList());
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(info)
                .enable(!flag)
                .groupName("袁哲")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.chinesenation.Controller"))
                //.paths(PathSelectors.ant("/user/**"))
                .build();
        return docket;
    }
}
